# Group User Emails

To add Alternate User Emails.

| Parameter | Description | Type | Required |
|:----------|-------------|------|----------|
| `email-address`  | Email Address of User | string | yes |
| `type` | Type of usage of User Email like personal, work etc | string | yes |


## User Email Admin Collection [/v1/admin/user-emails{?page%5bsize%5d,page%5bnumber%5d,sort,filter}]
+ Parameters
    + page%5bsize%5d (optional, integer, `10`) - Maximum number of resources in a single paginated response.
    + page%5bnumber%5d (optional, integer, `2`) - Page number to fetched for the paginated response.
    + sort (optional, string, `type`) - Sort the resources according to the given attribute in ascending order. Append '-' to sort in descending order.
    + filter (optional, string, `[]`) - Filter according to the flask-rest-jsonapi filtering system. Please refer: http://flask-rest-jsonapi.readthedocs.io/en/latest/filtering.html for more.

### List All User Emails [GET]
Get a list of User Emails.

+ Request

    + Headers

            Accept: application/vnd.api+json

            Authorization: JWT <Auth Key>

+ Response 200 (application/vnd.api+json)

        {
            "meta": {
                "count": 1
            },
            "data": [
                {
                    "relationships": {
                        "user": {
                            "links": {
                                "self": "/v1/user-emails/1/relationships/user",
                                "related": "/v1/alternate-emails/1/user"
                            }
                        }
                    },
                    "attributes": {
                        "user-id": 1,
                        "deleted-at": null,
                        "email-address": "example@example.com",
                        "type": "work"
                    },
                    "type": "user-email",
                    "id": "1",
                    "links": {
                        "self": "/v1/user-emails/1"
                    }
                }
            ],
            "jsonapi": {
                "version": "1.0"
            },
            "links": {
                "self": "/v1/admin/user-emails"
            }
        }



## User Email Collection [/v1/users/{user_id}/alternate-emails{?page%5bsize%5d,page%5bnumber%5d,sort,filter}]
+ Parameters
    + user_id: 1 (integer) - ID of the specific user in integer
    + page%5bsize%5d (optional, integer, `10`) - Maximum number of resources in a single paginated response.
    + page%5bnumber%5d (optional, integer, `2`) - Page number to fetched for the paginated response.
    + sort (optional, string, `type`) - Sort the resources according to the given attribute in ascending order. Append '-' to sort in descending order.
    + filter (optional, string, `[]`) - Filter according to the flask-rest-jsonapi filtering system. Please refer: http://flask-rest-jsonapi.readthedocs.io/en/latest/filtering.html for more.

### List All User Emails [GET]
Get a list of user emails.

+ Request

    + Headers

            Accept: application/vnd.api+json

            Authorization: JWT <Auth Key>

+ Response 200 (application/vnd.api+json)

        {
        "data": [
            {
                "type": "user-email",
                "id": "1",
                "relationships": {
                    "user": {
                        "links": {
                            "self": "/v1/user-emails/1/relationships/user",
                            "related": "/v1/alternate-emails/1/user"
                        }
                    }
                },
                "attributes": {
                    "user-id": 1,
                    "deleted-at": null,
                    "email-address": "example@example.com",
                    "type": "work"
                },
                "links": {
                    "self": "/v1/user-emails/1"
                }
            }
        ],
        "links": {
            "self": "/v1/users/1/alternate-emails"
        },
        "meta": {
            "count": 1
        },
        "jsonapi": {
            "version": "1.0"
        }
        }


## User Email Detail [/v1/user-emails/{user_email_id}]
+ Parameters
    + user_email_id: 1 (integer) - ID of the user_email in the form of an integer

### User Email Detail [GET]
Get a single user email.

+ Request

    + Headers

            Accept: application/vnd.api+json

            Authorization: JWT <Auth Key>

+ Response 200 (application/vnd.api+json)

        {
        "data": {
            "type": "user-email",
            "id": "1",
            "relationships": {
                "user": {
                    "links": {
                        "self": "/v1/user-emails/1/relationships/user",
                        "related": "/v1/alternate-emails/1/user"
                    }
                }
            },
            "attributes": {
                "user-id": 1,
                "deleted-at": null,
                "email-address": "example@example.com",
                "type": "work"
            },
            "links": {
                "self": "/v1/user-emails/1"
            }
        },
        "links": {
            "self": "/v1/user-emails/1"
        },
        "jsonapi": {
            "version": "1.0"
        }
        }

### Update User Email [PATCH]
Update a single user email with `id`.

+ `id` (integer) - ID of the record to update **(required)**

+ Request (application/vnd.api+json)

    + Headers

            Authorization: JWT <Auth Key>

    + Body

            {
                "data": {
                "attributes": {
                  "email-address": "hello@example.com",
                  "type": "office"
                },
                "relationships": {
                  "user": {
                    "data": {
                      "type": "user",
                      "id": "1"
                    }
                  }
                },
                "type": "user-email",
                "id": "1"
              }
            }

+ Response 200 (application/vnd.api+json)

        {
        "data": {
            "type": "user-email",
            "id": "1",
            "relationships": {
                "user": {
                    "links": {
                        "self": "/v1/user-emails/1/relationships/user",
                        "related": "/v1/alternate-emails/1/user"
                    }
                }
            },
            "attributes": {
                "user-id": 1,
                "deleted-at": null,
                "email-address": "hello@example.com",
                "type": "office"
            },
            "links": {
                "self": "/v1/user-emails/1"
            }
        },
        "links": {
            "self": "/v1/user-emails/1"
        },
        "jsonapi": {
            "version": "1.0"
        }
        }

### Delete User Email [DELETE]
Delete a single user email.

+ Request

    + Headers

            Accept: application/vnd.api+json

            Authorization: JWT <Auth Key>

+ Response 200 (application/vnd.api+json)

        {
          "meta": {
            "message": "Object successfully deleted"
          },
          "jsonapi": {
            "version": "1.0"
          }
        }
